package org.pictual.util;

public class Codificar {

	public static String removeSpacesForInformation(String s){
		return s.replaceAll(" ", "_");   //trimmedString;
	}

	public static String removeSpacesForImages(String s){
		s = cambiar(s);
		return s.replaceAll(" ","+");   //trimmedString;
	}

	public static String convertir(String query){
		
		query = query.replaceAll("Ã±" ,"ñ");
//		query = query.replaceAll("Ã‘" ,"Ñ");

//		query = query.replaceAll("Ã" ,"Á");		//CUIDADO
//		query = query.replaceAll("Ã‰" ,"É");
//		query = query.replaceAll("Ã" ,"Í");		//CUIDADO
//		query = query.replaceAll("Ã“" ,"Ó");
//		query = query.replaceAll("Ãš" ,"Ú");
		
		query = query.replaceAll("Ã¡" ,"á");
		query = query.replaceAll("Ã©" ,"é");
		query = query.replaceAll("Ã­" ,"í");
		query = query.replaceAll("Ã³" ,"ó");
		query = query.replaceAll("Ãº" ,"ú");
		
//		query = query.replaceAll("Ãœ" ,"Ü");
		query = query.replaceAll("Ã¼" ,"ü");

//		query = query.replaceAll("Ã–" ,"Ö");
		query = query.replaceAll("Ã¶" ,"ö");
		
		query = query.replaceAll("â‚¬" ,"€");
		query = query.replaceAll("â€š" ,"‚");
		query = query.replaceAll("Æ’" ,"ƒ");
		query = query.replaceAll("â€ž" ,"„");
		query = query.replaceAll("â€¦" ,"…");
		query = query.replaceAll("â€" ,"†");
		query = query.replaceAll("â€¡" ,"‡");
		query = query.replaceAll("Ë†" ,"ˆ");
		query = query.replaceAll("â€°" ,"‰");
		query = query.replaceAll("Å" ,"Š");
		query = query.replaceAll("â€¹" ,"‹");
		query = query.replaceAll("Å’" ,"Œ");
		query = query.replaceAll("Å½" ,"Ž");
		query = query.replaceAll("â€˜" ,"‘");
		query = query.replaceAll("â€™" ,"’");
		query = query.replaceAll("â€œ" ,"“");
		query = query.replaceAll("â€" ,"”");
		query = query.replaceAll("â€¢" ,"•");
		query = query.replaceAll("â€“" ,"–");
		query = query.replaceAll("â€”" ,"—");
		query = query.replaceAll("Ëœ" ,"˜");
		query = query.replaceAll("â„¢" ,"™");
		query = query.replaceAll("Å¡" ,"š");
		query = query.replaceAll("â€º" ,"›");
		query = query.replaceAll("Å“" ,"œ");
		query = query.replaceAll("Å¾" ,"ž");
		query = query.replaceAll("Å¸" ,"Ÿ");
		query = query.replaceAll("Â" ,"");
		query = query.replaceAll("Â¡" ,"¡");
		query = query.replaceAll("Â¢" ,"¢");
		query = query.replaceAll("Â£" ,"£");
		query = query.replaceAll("Â¤" ,"¤");
		query = query.replaceAll("Â¥" ,"¥");
		query = query.replaceAll("Â¦" ,"¦");
		query = query.replaceAll("Â§" ,"§");
		query = query.replaceAll("Â¨" ,"¨");
		query = query.replaceAll("Â©" ,"©");
		query = query.replaceAll("Âª" ,"ª");
		query = query.replaceAll("Â«" ,"«");
		query = query.replaceAll("Â¬" ,"¬");
		query = query.replaceAll("Â­" ,"");
		query = query.replaceAll("Â®" ,"®");
		query = query.replaceAll("Â¯" ,"¯");
		query = query.replaceAll("Â°" ,"°");
		query = query.replaceAll("Â±" ,"±");
		query = query.replaceAll("Â²" ,"²");
		query = query.replaceAll("Â³" ,"³");
		query = query.replaceAll("Â´" ,"´");
		query = query.replaceAll("Âµ" ,"µ");
		query = query.replaceAll("Â¶" ,"¶");
		query = query.replaceAll("Â·" ,"·");
		query = query.replaceAll("Â¸" ,"¸");
		query = query.replaceAll("Â¹" ,"¹");
		query = query.replaceAll("Âº" ,"º");
		query = query.replaceAll("Â»" ,"»");
		query = query.replaceAll("Â¼" ,"¼");
		query = query.replaceAll("Â½" ,"½");
		query = query.replaceAll("Â¾" ,"¾");
		query = query.replaceAll("Â¿" ,"¿");
//		query = query.replaceAll("Ã€" ,"À");
//		query = query.replaceAll("Ã‚" ,"Â");
//		query = query.replaceAll("Ãƒ" ,"Ã");
//		query = query.replaceAll("Ã„" ,"Ä");
//		query = query.replaceAll("Ã…" ,"Å");
		query = query.replaceAll("Ã†" ,"Æ");
		query = query.replaceAll("Ã‡" ,"Ç");
//		query = query.replaceAll("Ãˆ" ,"È");
//		query = query.replaceAll("ÃŠ" ,"Ê");
//		query = query.replaceAll("Ã‹" ,"Ë");
//		query = query.replaceAll("ÃŒ" ,"Ì");
//		query = query.replaceAll("ÃŽ" ,"Î");
//		query = query.replaceAll("Ã" ,"Ï");
		query = query.replaceAll("Ã" ,"Ð");
//		query = query.replaceAll("Ã’" ,"Ò");
//		query = query.replaceAll("Ã”" ,"Ô");
//		query = query.replaceAll("Ã•" ,"Õ");
		query = query.replaceAll("Ã—" ,"×");
		query = query.replaceAll("Ã˜" ,"Ø");
//		query = query.replaceAll("Ã™" ,"Ù");
//		query = query.replaceAll("Ã›" ,"Û");
		query = query.replaceAll("Ã" ,"Ý");
		query = query.replaceAll("Ãž" ,"Þ");
		query = query.replaceAll("ÃŸ" ,"ß");
		query = query.replaceAll("Ã" ,"à");
		query = query.replaceAll("Ã¢" ,"â");
		query = query.replaceAll("Ã£" ,"ã");
		query = query.replaceAll("Ã¤" ,"ä");
		query = query.replaceAll("Ã¥" ,"å");
		query = query.replaceAll("Ã¦" ,"æ");
		query = query.replaceAll("Ã§" ,"ç");
		query = query.replaceAll("Ã¨" ,"è");
		query = query.replaceAll("Ãª" ,"ê");
		query = query.replaceAll("Ã«" ,"ë");
		query = query.replaceAll("Ã¬" ,"ì");
		query = query.replaceAll("Ã®" ,"î");
		query = query.replaceAll("Ã¯" ,"ï");
		query = query.replaceAll("Ã°" ,"ð");
		query = query.replaceAll("Ã²" ,"ò");
		query = query.replaceAll("Ã´" ,"ô");
		query = query.replaceAll("Ãµ" ,"õ");
		query = query.replaceAll("Ã·" ,"÷");
		query = query.replaceAll("Ã¸" ,"ø");
		query = query.replaceAll("Ã¹" ,"ù");
		query = query.replaceAll("Ã»" ,"û");
		query = query.replaceAll("Ã½" ,"ý");
		query = query.replaceAll("Ã¾" ,"þ");
		query = query.replaceAll("Ã¿" ,"ÿ");

		return query;
	}

	public static String cambiar(String query2){
		query2 = query2.replaceAll("%C3%83%C2%A1", "Ã¡");
		query2 = query2.replaceAll("%C3%83%C2%A9", "Ã©");
		query2 = query2.replaceAll("%C3%83%C2%AD", "Ã­");
		query2 = query2.replaceAll("%C3%83%C2%B3", "Ã³");
		query2 = query2.replaceAll("%C3%83%C2%BA", "Ãº");
		query2 = query2.replaceAll("%C3%83%C2%B1", "Ã±");
		query2 = query2.replaceAll("%C3%83%C2%BC", "Ã¼");
		query2 = query2.replaceAll("%C3%83%C2%AB","Ã«");
		query2 = query2.replaceAll("%C3%83%C2%AF", "Ã¯");
		query2 = query2.replaceAll("%C3%83%C2%B6", "Ã¶");
		query2 = query2.replaceAll("%C3%83%C2%A4", "Ã¤");
		query2 = query2.replaceAll("%C2%81%C2%A2", "ï�¢");
		query2 = query2.replaceAll("%C3%83%C2%A2", "Ã¢");
		query2 = query2.replaceAll("%C3%83%C2%AA", "Ãª");
		query2 = query2.replaceAll("%C3%83%C2%AE", "Ã®");
		query2 = query2.replaceAll("%C3%83%C2%B4", "Ã´");
		query2 = query2.replaceAll("%C3%83%C2%BB", "Ã»");
		query2 = query2.replaceAll("%C3%83%C2%A0", "Ã ");
		query2 = query2.replaceAll("%C3%83%C2%A8", "Ã¨");
		query2 = query2.replaceAll("%C3%83%C2%AC", "Ã¬");
		query2 = query2.replaceAll("%C3%83%C2%B2", "Ã²");
		query2 = query2.replaceAll("%C3%83%C2%B9", "Ã¹");
		query2 = query2.replaceAll("%C3%83%C2%BF", "Ã¿");
		query2 = query2.replaceAll("%C3%83%C2%81", "Ã�");
		query2 = query2.replaceAll("%C3%83%C2%89", "Ã‰");
		query2 = query2.replaceAll("%C3%83%C2%8D", "Ã�");
		query2 = query2.replaceAll("%C3%83%C2%93", "Ã“");
		query2 = query2.replaceAll("%C3%83%C2%9A", "Ãš");
		query2 = query2.replaceAll("%C3%83%C2%80", "Ã€");
		query2 = query2.replaceAll("%C3%83%C2%88", "Ã‰");
		query2 = query2.replaceAll("%C3%83%C2%8C", "Ã�");
		query2 = query2.replaceAll("%C3%83%C2%92", "Ã“");
		query2 = query2.replaceAll("%C3%83%C2%99", "Ãš");
		query2 = query2.replaceAll("%C3%83%C2%84", "Ã„");
		query2 = query2.replaceAll("%C3%83%C2%8B", "Ã‹");
		query2 = query2.replaceAll("%C3%83%C2%8F", "Ã�");
		query2 = query2.replaceAll("%C3%83%C2%96", "Ã–");
		query2 = query2.replaceAll("%C3%83%C2%9C", "Ãœ");
		query2 = query2.replaceAll("%C3%85%C2%93", "Å“");
		query2 = query2.replaceAll("%C3%83%C2%A7", "Ã§");
		query2 = query2.replaceAll("%C3%83%C2%9F", "ÃŸ");
		return query2;
	}
	
	public static void main(String[] args) {
		String cadena = "pinguino".toLowerCase().trim();
		
		System.out.println(Codificar.convertir(cadena));
		
	}
}
